-
Notifications
You must be signed in to change notification settings - Fork 96
Fixed an issue where rendering extremely thin strokes would appear broken. #936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where extremely thin strokes would appear broken or discontinuous during rendering. The fix involves treating very thin strokes as hairline strokes with alpha adjustments to simulate their appearance.
- Adds detection logic to identify strokes that are too thin after transformation and treat them as hairlines
- Implements alpha adjustment for thin strokes to maintain visual fidelity
- Refactors stroke utility functions from ApplyStrokeToBounds.h to StrokeUtils.h for better organization
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/core/utils/StrokeUtils.h | Adds TreatStrokeAsHairline function declaration and Matrix include |
src/core/utils/StrokeUtils.cpp | Implements logic to detect thin strokes that should be treated as hairlines |
src/core/StyledShape.h | Adds convertToHairlineIfNecessary method declaration |
src/core/StyledShape.cpp | Implements hairline conversion with alpha adjustment for thin strokes |
src/layers/ShapeLayer.cpp | Updates stroke rendering to use new thin stroke detection logic |
src/gpu/OpsCompositor.cpp | Integrates hairline conversion into the rendering pipeline |
include/tgfx/layers/ShapeLayer.h | Updates createStrokeShape method signature |
include/tgfx/layers/Layer.h | Makes getGlobalMatrix method public |
Multiple files | Updates include statements to use new StrokeUtils.h header |
Test files | Adds regression tests for extremely thin stroke rendering |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…mely_thin_stroke_broken
std::vector<Paint> strokePaints = {}; | ||
std::shared_ptr<Shape> strokeShape = nullptr; | ||
if (!_strokeStyles.empty()) { | ||
bool isHairlineRender = stroke.isHairline() || TreatStrokeAsHairline(stroke, getGlobalMatrix()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
创建图层内容的时候不能通过getGlobalMatrix来判断,图层的矩阵是一直会变化的,而图层内容不会更新。
修复渲染极度细的描边会断断续续的问题